package com.example.allshengmedical.experimentrun.activity;

import java.text.SimpleDateFormat;

import com.example.allshengmedical.R.id;
import com.example.allshengmedical.util.ByAlert;

import android.R.integer;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.util.Log;
import android.widget.TextView;

public class TimeCountUtils {
	int s, mm, hh, now;

	public int TimeCalculation(String time) {
		s = Integer.parseInt(time.substring(time.lastIndexOf(":") + 1,
				time.length())) * 1000;
		mm = Integer.parseInt(time.substring(time.indexOf(":") + 1,
				time.lastIndexOf(":"))) * 1000 * 60;
		hh = Integer.parseInt(time.substring(0, time.indexOf(":"))) * 60000 * 60;
		return s + mm + hh;
	}

	public String allTime(int t) {
		long tine = t;
		SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
		String timeString = dateFormat.format(tine);
		return timeString;

	}

	public static String secToTime(int time) {
		time = time / 1000;
		String timeStr = null;
		int hour = 0;
		int minute = 0;
		int second = 0;
		if (time <= 0)
			return "00:00:00";
		else {
			minute = time / 60;
			if (minute < 60) {
				second = time % 60;
				timeStr = "00:" + unitFormat(minute) + ":" + unitFormat(second);
			} else {
				hour = minute / 60;
				if (hour > 99)
					return "99:59:59";
				minute = minute % 60;
				second = time - hour * 3600 - minute * 60;
				timeStr = unitFormat(hour) + ":" + unitFormat(minute) + ":"
						+ unitFormat(second);
			}
		}
		return timeStr;
	}

	public static String unitFormat(int i) {
		String retStr = null;
		if (i >= 0 && i < 10)
			retStr = "0" + Integer.toString(i);
		else
			retStr = "" + i;
		return retStr;
	}

	/**
	 * 温度1 温度2
	 */
	public static int tempChangeTime(String temp1, String temp2) {
		int tempAbs = Math.abs(Integer.parseInt(temp1)
				- Integer.parseInt(temp2));
		return tempAbs * 1000;
		// return 1000;
	}

	public static boolean tempCompare(String temp1, String temp2) {
		if (Integer.parseInt(temp1) < Integer.parseInt(temp2)) {
			return true;
		} else {
			return false;
		}
	}
}
